import numpy as np
from utils.bbox_utils import xyxy2xyah, xyxy2xywh


class Detection(object):
    """检测框对象
    input:
        (xyxy, conf, class)
    """

    def __init__(self, output_tensor, feature):
        self.xyxy = np.asarray(output_tensor[:4], dtype=np.float32)
        self.confidence = output_tensor[4]
        self.feature = np.asarray(feature, dtype=np.float32)

    def to_xyah(self):
        return xyxy2xyah(self.xyxy)

    def to_xywh(self):
        return xyxy2xywh(self.xyxy)
